package com.usefullc.common.enums;


import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 校验类型
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum ValidTypeEnum {


    EMPTY(-1, "空白"),

    EMAIL(0, "邮箱"),

    PHONE(1, "电话"),

    MOBILE(2, "手机"),

    URL(3, "URL"),

    ZIP_CODE(4, "邮编"),

    ID_CARD(5, "身份证"),

    BANK_CARD(6, "银行卡"),

    MONEY(7, "金额"),

    DIGIT(8, "整数"),

    DATE(9, "时间"),

    REGEX(10, "正则"),

    ;


    private int code;
    private String value;

    ValidTypeEnum(int code, String value) {
        this.code = code;
        this.value = value;
    }

    public static ValidTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (ValidTypeEnum s : ValidTypeEnum.values()) {
            if (s.getCode() == code) {
                return s;
            }
        }
        return null;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}
